package dmas.lab.tasks;

import java.math.BigInteger;
import java.util.Random;

import dmas.lab.models.Message;
import dmas.lab.schedulers.Event;
import dmas.lab.schedulers.Scheduler;
import dmas.lab.schedulers.TaskCaller;

public class ReceiveMessageEvent extends Event {

	private final Message message;

	public ReceiveMessageEvent(BigInteger ID, TaskCaller taskCaller, Message message) {
		super(ID, taskCaller);
		this.message = message;
	}

	@Override
	public Event runTask() throws Exception {
		Scheduler scheduler = (Scheduler) getCallback();
		scheduler.addEvent(new SendSpamEvent(BigInteger.probablePrime(16, new Random()), scheduler, message.reversed()));
		return this;
	}
}
